#ifndef _OBJLOADER_
#define _OBJLOADER_

#include "Vector3.h"

#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <fstream>
#include <iostream>
#include <vector>
#include <map>

#define GL_GLEXT_PROTOTYPES 1

#ifdef WIN32
#include <Windows.h>
#endif

#include <GL/glew.h>

class CVector3
{
	public:
	float x, y, z;
};

class CVector2
{
	public:
	float x, y;
};

struct tFace
{
	bool isQuad;
	int vertIndex[4];
	int normIndex[4];
	int coordIndex[4];
};

struct t3DObject
{
	int  numOfVerts;
	int  numOfFaces;
	int  numTexVertex;
	int  numNormals;
	int  materialID;
	bool bHasTexture;
	char strName[255];
	CVector3  *pVerts;
	CVector3  *pNormals;
	CVector2  *pTexVerts;
	tFace *pFaces;
	std::multimap <int, int> sharedfaces;
	std::map<int, Vec3> smoothedtangents;
};


class ObjLoader {

public:
	ObjLoader();
	~ObjLoader( void );
	static GLuint LoadObj(const char *strFileName);
	typedef std::multimap<int,int>::iterator facesiterator;

private:
	static Vec3 computeFaceTangent(int faceIndex,t3DObject *t);
};

#endif  
